<?php
/**
 * MongoDig
 *
 * @copyright  Copyright (c) 2010 lanyanguang (http://www.lanyg.com)
 * @license    GNU General Public License 2.0
 * @version    $Id$
 */

/** user逻辑操作 */

//插入一个用户
function user_insert($user)
{
	global $db;
	$collection = $db->user;
	$collection->insert($user);
}

//批量添加用户
function user_insert_patch($users)
{
	global $db;
	$collection = $db->user;
	$collection->batchInsert($users);
}

//删除一个用户
function user_delete($filter)
{
	global $db;
	$collection = $db->user;
	$collection->remove($filter);
}

//更新一个用户信息
function user_update($filter,$user)
{
	global $db;
	$collection = $db->user;
	$collection->update($filter,$user);
}

//查找一个用户信息
function user_find_one($filter)
{
	global $db;
	$collection = $db->user;
	return $user = $collection->findOne($filter);
}

//查找用户信息
function user_find($filter='')
{
	global $db;
	$collection = $db->user;
	if(empty($filter)){
		return $user = $collection->find();
	}else{
		return $user = $collection->find($filter);
	}
}